﻿using System;
using System.Collections.Generic;
using System.Linq;
using MartinRL.ProjectEuler.Sequences;

namespace MartinRL.ProjectEuler
{
    /// <summary>
    /// http://projecteuler.net/index.php?section=problems&id=6
    /// </summary>
    public static class Problem006
    {
        public static int FindTheDifferenceBetweenTheSumOfTheSquaresOfTheFirstOneHundredNaturalNumbersAndTheSquareOfTheSum()
        {
            var first100NaturalNumbers = 1.To(100);
            var squareOfTheSum = first100NaturalNumbers.Sum().Sqr();
            var sumOfTheSquares = first100NaturalNumbers.Select(t => t.Sqr()).Sum();
            
            return squareOfTheSum - sumOfTheSquares;
        }
    }
}